package com.hayrullah.cinema.Dao;

import java.util.List;

import org.hibernate.HibernateException;
import org.hibernate.Session;

import com.hayrullah.cinema.Util.HibernateUtil;
import com.hayrullah.cinema.entity.Seans;

public class SeansDao extends AbstractDao<Seans>{

	@Override
	public Seans findById(Long id) {
		Seans seans =null;
		try {
			Session session = HibernateUtil.getSessionFactory().getCurrentSession();
			session.beginTransaction();
			seans= (Seans)session.get(Seans.class, id);
			session.getTransaction().commit();
		} catch (HibernateException exception) {
			exception.printStackTrace();
		}
		
		return seans;
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<Seans> findAll() {
		List<Seans> seans = null;
		try {
			Session session = HibernateUtil.getSessionFactory().getCurrentSession();
			session.beginTransaction();
			seans = (List<Seans>) session.createCriteria(Seans.class).list();
			session.getTransaction().commit();
		} catch (HibernateException e) {

		}
		return seans;
	}

	


}
